package com.luck.easyfoodbatch.ui;

import android.annotation.TargetApi;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import com.luck.easyfoodbatch.MainActivity;
import com.luck.easyfoodbatch.R;
import com.luck.easyfoodbatch.runtimepermissions.PermissionsManager;
import com.luck.easyfoodbatch.runtimepermissions.PermissionsResultAction;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LoadingActivity extends BaseNoSliderActivity {

    @BindView(R.id.iv_banner)
    ImageView ivBanner;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        ButterKnife.bind(this);

        // requestPermissions();
        //渐变展示启动屏
        AlphaAnimation aa = new AlphaAnimation(1.0f, 1.0f);
        aa.setDuration(1000);
        ivBanner.startAnimation(aa);
        aa.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation arg0) {
                ivBanner.setVisibility(View.VISIBLE);
                startAct(MainActivity.class);
                overridePendingTransition(R.anim.fade, R.anim.hold);
                finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
                ivBanner.setVisibility(View.VISIBLE);
            }
        });
    }

    @TargetApi(23)
    private void requestPermissions() {
        PermissionsManager.getInstance().requestAllManifestPermissionsIfNecessary(this, new PermissionsResultAction() {
            @Override
            public void onGranted() {
//				Toast.makeText(MainActivity.this, "All permissions have been granted", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onDenied(String permission) {
                //Toast.makeText(MainActivity.this, "Permission " + permission + " has been denied", Toast.LENGTH_SHORT).show();
            }
        });
    }


}
